// 
// SharedGuiTypes.cs
//  
// Author:
//       Tomas Vondracek <tomas.vondracek@gmail.com>
// 
// Copyright (c) 2010 Tomas Vondracek
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

using System;
using System.Windows.Forms;

/// contains shared gui types used from guiwinformslib
namespace Common.Interfaces
{	
	/// <summary>
	/// Dockable panel alignment in main form. The panel is held by a DockingContainer. 
	/// This DocingContainer has its dock style in main form.
	/// The alignment is determined by container docking style.
	/// If container is on bottom or top, the alignment is horizontal + concrete side.
	/// If container is docked on right or left, the alignment is vertical + concrete side.
	/// </summary>
	public enum PanelAlignment
	{
		VerticalLeft,
		HorizontalBottom,
		HorizontalTop,
		VerticalRight,
		None
	}


	/// <summary>
	/// possible states for (floating) dockable panels
	/// </summary>
	/// <remarks>
	/// autohiding isn't used yet
	/// </remarks>
	public enum DockablePanelState
	{
		Hidden,
		Normal,
		Maximalized,
		Floating,
		AutoHiding
	}
	
	
	public delegate void DockablePanelStateChanged(object sender);
	public delegate void PluginShortcutClicked(object sender, EventArgs e);
	public delegate void PanelAlignmentChanged(object sender, AlignmentEventArgs ae);

	public class AlignmentEventArgs : EventArgs
	{
		PanelAlignment alignment;
		Control panel;

		public Control Panel
		{
			get { return panel; }
		}

		public PanelAlignment Alignment
		{
			get { return alignment; }
		}

		public AlignmentEventArgs(PanelAlignment alignment, Control panel)
		{
			this.alignment = alignment;
			this.panel = panel;
		}
	}

	public interface IView
	{
		void ShowView();
		void HideView();
		bool IsVisible
		{
			get;
		}
	}

	/// <summary>
	/// represents dockable panel, that can be used by plugin and hold its controls,
	/// gui controls in host application must inherit and use this interface.
	/// Dockable panels (floating ones too) are docked in docking containers,
	///  which are placed on edges of main form
	/// </summary>
	public interface IDockablePanel : IView
	{
		/// <summary>
		/// occurs when dockable panel changes its state
		///  - minimize, restore, floating...
		/// </summary>
		event DockablePanelStateChanged HandleDockablePanelStateChanged;

		/// <summary>
		/// occurs when the title of panel is changed
		/// </summary>
		event EventHandler DockablePanelTitleTextChanged;
		
		/// <summary>
		/// the title text displayed in dockable panel header
		/// </summary>
		string TitleText
		{
			get;
			set;
		}

		/// <summary>
		/// the height of control bar.
		/// Control bar is used as panel header and contains
		/// control buttons for changing dockable panel state
		/// </summary>
		int ControlsBarHeight
		{
			get;
			set;
		}

		/// <summary>
		/// context menu for dockinable panel
		/// </summary>
		System.Windows.Forms.ContextMenu ContextMenu
		{
			get;
			set;
		}
		
		/// <summary>
		/// Dockable panel alignment.
		/// The panel is hold by a DockinContainer. This DocingContainer is docked in main form.
		/// The alignment is determined by container docking style.
		/// If container is on bottom or top, the alignment is horizontal.
		/// If container is docked on right or left, the alignment os vertical + concrete side.
		/// </summary>
		PanelAlignment Alignment
		{
			get;
			set;
		}

		/// <summary>
		/// current state of the dockable panel
		/// </summary>
		DockablePanelState CurrentState
		{
			get;
			set;
		}

		/// <summary>
		/// add control as a DockablePanel content
		/// </summary>
		/// <param name="ctrl"></param>
		void AddContent(Control ctrl);

		/// <summary>
		/// preferred minimum size
		/// </summary>
		System.Drawing.Size PreferredMinimumSize
		{
			get;
		}
	}
}
